package com.vegetable.modules.mapper.finance;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vegetable.modules.entity.finance.Transactions;
import com.vegetable.modules.entity.finance.po.TransactionsQueryPO;
import com.vegetable.modules.entity.finance.vo.TradingFlowStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 其他收款 Mapper 接口
 * </p>
 *
 * @author wangruijie
 * @since 2024-04-15
 */
@Mapper
public interface TransactionsMapper extends BaseMapper<Transactions> {

    List<TradingFlowStatisticsVO> statisticsFlow(TransactionsQueryPO po);

    int insertIgnoreBatch(List<Transactions> transactions);


    List<Map<String, Object>> analysisTransINCOME(Date startTime, Date endTime);
    List<Map<String, Object>> analysisTransEXPENSE(Date startTime, Date endTime);

    List<Transactions> duplicateData();

    /**
     * 查询未匹配的交易流水，按交易时间升序排列
     * @return 交易流水列表
     */
    @Select("SELECT * FROM transactions WHERE id NOT IN (SELECT transaction_id FROM transaction_payment_match) ORDER BY trading_time ASC")
    List<Transactions> selectUnmatchedTransactions();
}